package com.qidianit.mes.pro.controller;

import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.WorkFlowProcess;
import com.qidianit.mes.pro.service.WorkFlowProcessService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/17 19:02
 */
@RestController
@RequestMapping("/workflowProcess")
public class WorkFlowProcessController {
    @Autowired
    private WorkFlowProcessService workFlowProcessService;

    /**
     * 查询工序组成
     * @param workflowId
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public Result selectWorkFlowProcessPage(@Param("workflowId") Long workflowId,
                                            @Param("page") @RequestParam(defaultValue = "1") int page,
                                            @Param("pageSize") @RequestParam(defaultValue = "10") int pageSize ){
        return workFlowProcessService.selectWorkFlowProcessList(workflowId,page,pageSize);
    }

    /**
     * 新增工序组成
     * @param workFlowProcess
     * @return
     */
    @PostMapping("/add")
    public Result addWorkFlowProcess(@RequestBody WorkFlowProcess workFlowProcess){
        return workFlowProcessService.addWorkFlowProcess(workFlowProcess);
    }

    /**
     * 根据id获取工序组成
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getWorkFlowProcessById(@PathVariable Long id){
        return workFlowProcessService.getWorkFlowProcessById(id);
    }

    /**
     * 更新工序组成
     * @param workFlowProcess
     * @return
     */
    @PutMapping("/update")
    public Result updateWorkFlowProcess(@RequestBody WorkFlowProcess workFlowProcess){
        return workFlowProcessService.updateWorkFlowProcess(workFlowProcess);
    }

    /**
     * 根据id删除工序组成
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteWorkFlowProcessById(@PathVariable Long id){
        return workFlowProcessService.deleteWorkFlowProcessById(id);
    }

    /**
     * 批量删除工序组成
     * @param id
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDeleteWorkFlowProcess(@RequestBody Long[] id){
        return workFlowProcessService.batchDeleteWorkFlowProcess(id);
    }
}
